﻿@using System.Configuration
@using Matrix.MaKaYunShang.BLL
@{
    ViewBag.Title = "卡券管理";
    ViewBag.PathToBtn = "/CloudCards/Create";
    ViewBag.TextBtn = "创建卡券";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-body">
                卡券名称：<input type="text" class="form-control input-sm" placeholder="卡券名称" style="width: 110px;display: inline-block" id="keyWord" />
                &nbsp;&nbsp;
                卡券类别：
                <select id="cateId" class="form-control input-sm" style="width: 110px;display: inline-block">
                    <option value="0">全部</option>
                    @{
                        var cateList = CardCategoryBLL.Instance.GetModelList();
                        foreach (var item in cateList)
                        {
                            <option value="@item.Id">@item.CategoryName</option>
                        }
                    }
                </select>
                &nbsp;&nbsp;
                卡券状态：
                <select id="status" class="form-control input-sm" style="width: 110px;display: inline-block">
                    <option value="-1">全部</option>
                    <option value="0">待审核</option>
                    <option value="1">审核通过</option>
                    <option value="2">审核未通过</option>
                </select>
                &nbsp;&nbsp;
                <a class="btn btn-primary pull-right" id="btnSearch">查询</a>
            </div>
        </div>
    </div>
</div>
<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                卡券列表
            </div>
            <div class="panel-body">
                <div class="dataTable_wrapper">
                    <table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
                        <thead>
                            <tr>
                                <th>卡券名称</th>
                                <th>卡券类别</th>
                                <th>是否在主页显示</th>
                                <th>状态</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody></tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
@section javascript{
    <script src="/Content/admin/dist/js/pagingHelper.js"> </script>
    <script type="text/javascript">
        var dataParams = {};
        var serverProcessPath = "/CloudCards/Listing";
        var showColumns = [
            { data: "CardName" },
            { data: "CategoryName" },
            { data: "ShowOnHomepageText" },
            { data: "CardStatusText" },
            { data: "Action" }
        ];
        pagingHelper.Paging(serverProcessPath, dataParams, showColumns);
        $("#dataTables-example_wrapper div:first").hide();

        $(function() {
            $("#btnSearch").click(function() {
                reloadList();
            });
        });

        function updateData(id) {
            document.location.href = '/CloudCards/Update/' + id;
        }

        function deleteData(id) {
            alertify.okBtn("确定").cancelBtn("取消").confirm("确定要删除该数据吗？", function () {
                $.ajax({
                    type: 'post',
                    async: false,
                    url: '/CloudCards/Delete',
                    data: { doIds: id },
                    success: function (result) {
                        if (result) {
                            alertify.success("数据删除成功");
                            pagingHelper.reload();
                        } else {
                            alertify.error("数据删除失败");
                        }
                    }
                });
            });
        }

        function reloadList() {
            pagingHelper.reloadWithDiffPath("@Url.Action("Listing")" + "?keyWord=" + $("#keyWord").val() + "&cateId=" + $("#cateId").val() + "&status=" + $("#status").val());
        }
    </script>
}